package com.wsx.ones.monitor.core.codec.rpc;

import com.wsx.ones.monitor.core.codec.AbstractCodec;
import com.wsx.ones.monitor.core.model.RpcRequest;
import com.wsx.ones.monitor.core.model.RpcResponse;
import com.wsx.ones.monitor.core.transport.Channel;

import java.io.IOException;

/**
 * 编码的实际实现类
 * Created by wangshuaixin on 17/2/4.
 */
public class DefaultRpcCodec extends AbstractCodec {

    /**
     *
     * @param channel
     * @param message
     * @return
     * @throws IOException
     */
    public byte[] encode(Channel channel, Object message) throws IOException {

        if (message instanceof RpcRequest) {
            return encodeRpcRequest(channel, (RpcRequest)message);
        } else if (message instanceof RpcResponse) {

        }
        return new byte[0];
    }

    /**
     *
     * @param channel
     * @param remoteIp
     * @param bytes
     * @return
     * @throws IOException
     */
    public Object decode(Channel channel, String remoteIp, byte[] bytes) throws IOException {
        return null;
    }

    private byte[] encodeRpcRequest(Channel channel, RpcRequest message) {
        return new byte[0];
    }

}
